package com.hrm.model.serviceimple;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.hrm.model.dao.CodeDAO;
import com.hrm.model.dto.code.CodeDTO;
import com.hrm.model.service.CodeService;

public class CodeServiceImple implements CodeService {
	private CodeDAO codeDAO;

	public void setCodeDAO(CodeDAO codeDAO) {
		this.codeDAO = codeDAO;
	}

	
	@Override
	public List<CodeDTO> getAllCode(CodeDTO dto) {
		return codeDAO.getAllCode(dto);
	}
	
	@Override
	public boolean updateCode(CodeDTO dto) {
			return codeDAO.updateCode(dto);
	}

	@Override
	public boolean insertCode(CodeDTO dto) {
		if(codeDAO.getCodeCount(dto) == 1){
			return codeDAO.insertDetailCode(dto);
		}else{
			if( codeDAO.insertCode(dto)){
				return codeDAO.insertDetailCode(dto);
			}
		}
		return false;		
	}

	@Override
	public List<CodeDTO> getAllKind() {
		return codeDAO.getAllKind();
	}
	
}
